<template>
    <el-dialog title="捐赠记录" :close-on-click-modal="false" :visible.sync="visible">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
                <el-input v-model="dataForm.key" placeholder="查询参数" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="getDataList()">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
            style="width: 100%;">
            <el-table-column prop="nickName" header-align="center" align="center" label="用户昵称">
            </el-table-column>
            <el-table-column prop="phone" header-align="center" align="center" label="手机">
            </el-table-column>
            <el-table-column prop="agentName" header-align="center" align="center" label="代理商">
            </el-table-column>
            <el-table-column prop="donateNum" header-align="center" align="center" label="捐赠数量">
            </el-table-column>
            <el-table-column prop="createTime" header-align="center" align="center" label="创建时间">
            </el-table-column>
        </el-table>
        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
            layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
    </el-dialog>
</template>

<script>
import * as api from '@/api/benefitActivityRecord.js'
export default {
    data() {
        return {
            visible: false,
            dataForm: {
                key: '',
                activityId: undefined
            },
            dataList: [],
            pageIndex: 1,
            pageSize: 10,
            totalPage: 0,
            dataListLoading: false,
            dataListSelections: [],
            addOrUpdateVisible: false
        }
    },
    activated() {
        this.getDataList()
    },
    methods: {
        init(id) {
            this.dataForm.activityId = id
            this.visible = true
        },
        // 获取数据列表
        getDataList() {
            this.dataListLoading = true
            api.benefitActivityRecordListApi().then(res => {
                // TODO 获取数据列表
                this.dataList = res.list
                this.totalPage = res.totalPage
                this.dataListLoading = false
            })
        },
        // 每页数
        sizeChangeHandle(val) {
            this.pageSize = val
            this.pageIndex = 1
            this.getDataList()
        },
        // 当前页
        currentChangeHandle(val) {
            this.pageIndex = val
            this.getDataList()
        },
        // 多选
        selectionChangeHandle(val) {
            this.dataListSelections = val
        },
    }
}

</script>